package com.amos.muexamclient.sys.controller;

import com.amos.bean.Result;
import com.amos.muexamclient.sys.service.SysConfigService;
import com.amos.muexamclient.sys.service.dto.SysConfigDTO;
import com.amos.muexamcore.core.BasePageController;
import com.amos.muexamcore.core.BasePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Copyright © 2018 五月工作室. All rights reserved.
 *
 * @Package com.amos.muexamclient.sys.controller
 * @ClassName SysConfigController
 * @Description TODO
 * @Author Amos
 * @Modifier
 * @Date 2020-03-24 14:33:05
 * @Version 1.0
 **/
@RestController
@RequestMapping(value = "/sys/config")
public class SysConfigController extends BasePageController<SysConfigDTO> {
    @Autowired
    private SysConfigService sysConfigService;

    @Override
    public BasePageService<SysConfigDTO> getPageService() {
        return sysConfigService;
    }

    /**
     * 条件查询
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/list")
    public Result list(@RequestBody SysConfigDTO dto) {
        return Result.success(sysConfigService.select(dto));
    }

    /**
     * 根据参数键名查询参数值
     *
     * @param configKey
     * @return
     */
    @GetMapping(value = "/configKey/{configKey}")
    public Result getConfigKey(@PathVariable("configKey") String configKey) {
        return Result.success(sysConfigService.getConfigKey(configKey));
    }
}
